/*
 * Groups.java
 *
 * Created on 30 wrzesień 2007, 18:51
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package info.mikrotubula.db;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Entity class Groups
 * 
 * @author Krystian
 */
@Entity
@Table(name = "GROUPS")
@NamedQueries( {
        @NamedQuery(name = "Groups.findByGrpId", query = "SELECT g FROM Groups g WHERE g.grpId = :grpId"),
        @NamedQuery(name = "Groups.findByGrpName", query = "SELECT g FROM Groups g WHERE g.grpName = :grpName"),
        @NamedQuery(name = "Groups.findAll", query = "SELECT g FROM Groups g")
    })
public class Groups implements Serializable {

    @Id
    @Column(name = "GRP_ID", nullable = false)
    private Integer grpId;

    @Column(name = "GRP_NAME", nullable = false)
    private String grpName;

    @OneToMany(mappedBy = "rghGrpId", fetch=FetchType.LAZY)
    private List<Rights> rights;
    
    /** Creates a new instance of Groups */
    public Groups() {
    }

    /**
     * Creates a new instance of Groups with the specified values.
     * @param grpId the grpId of the Groups
     */
    public Groups(Integer grpId) {
        this.grpId = grpId;
    }

    /**
     * Creates a new instance of Groups with the specified values.
     * @param grpId the grpId of the Groups
     * @param grpName the grpName of the Groups
     */
    public Groups(Integer grpId, String grpName) {
        this.grpId = grpId;
        this.grpName = grpName;
    }

    /**
     * Gets the grpId of this Groups.
     * @return the grpId
     */
    public Integer getGrpId() {
        return this.grpId;
    }

    /**
     * Sets the grpId of this Groups to the specified value.
     * @param grpId the new grpId
     */
    public void setGrpId(Integer grpId) {
        this.grpId = grpId;
    }

    /**
     * Gets the grpName of this Groups.
     * @return the grpName
     */
    public String getGrpName() {
        return this.grpName;
    }

    /**
     * Sets the grpName of this Groups to the specified value.
     * @param grpName the new grpName
     */
    public void setGrpName(String grpName) {
        this.grpName = grpName;
    }


    /**
     * Returns a hash code value for the object.  This implementation computes 
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.grpId != null ? this.grpId.hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this Groups.  The result is 
     * <code>true</code> if and only if the argument is not null and is a Groups object that 
     * has the same id field values as this object.
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Groups)) {
            return false;
        }
        Groups other = (Groups)object;
        if (this.grpId != other.grpId && (this.grpId == null || !this.grpId.equals(other.grpId))) return false;
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs 
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "info.mikrotubula.db.Groups[grpId=" + grpId + "]";
    }

    public List<Rights> getRights() {
        return rights;
    }

    public void setRights(List<Rights> rights) {
        this.rights = rights;
    }
    
}
